﻿using System;

namespace Variations
{
    class Variations
    {
        static int[] variation;

        static void PrintResult(int indexLength)
        {
            for (int index = 0; index < indexLength; index++)
            {
                Console.Write("{0} ", variation[index] + 1);
            }
            Console.WriteLine();
        }

        static void GenerateVariations(int index, int variationLength, int number)
        {
            if (index >= variationLength)
            {
                PrintResult(variationLength);
                return;
            }

            for (int j = 0; j < number; j++)
            {
                variation[index] = j;
                GenerateVariations(index + 1, variationLength , number);
            }
        }

        static void Main()
        {
            int n = 3;
            int k = 3;
            variation = new int[k];
            GenerateVariations(0, k, n);
        }
    }
}